import { _decorator, Component, Node, instantiate, v3, SpriteFrame, tween, director, EventTouch, Label, macro } from 'cc';
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = LocalStorageMgr
 */
 
@ccclass('LocalStorageMgr')
export default class LocalStorageMgr {
    private static _instance: LocalStorageMgr | null = null;

    gameName="Drawpoker";
    GetItemInt(name:string,nodata:number) {
        let str =localStorage.getItem(this.gameName+name);
        let num = nodata;
        if (str === "" || str === null || str === undefined) {

        }else
        {
            num = parseInt(str);
        }
        return num;
    }
    
    SetItem(name:string,data) {
        let str =localStorage.setItem(this.gameName+name,data.toString());
    }

    GetItemString(name:string,nodata) {
        let str =localStorage.getItem(this.gameName+name);
        if (str === "" || str === null || str === undefined) {
            str = nodata;
        }
        return str;
    }

    // 清缓存=============================================================
    removeAll() {
        
    }


    public static get Instance() {
        return LocalStorageMgr._instance || (LocalStorageMgr._instance = new LocalStorageMgr());
    }
}
